package com.cuit.food.food.Controller;

import Api.food.DFoodApi;
import com.cuit.food.DTO.RestruantDTO;
import com.cuit.food.Food;
import com.cuit.food.Usercomment;
import com.cuit.food.food.Dao.FoodRepostory;
import com.cuit.food.food.Service.DFoodService;
import common.result.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@CrossOrigin
public class DFoodController implements DFoodApi {
    @Autowired
    DFoodService dFoodService;


    /**
     * 查找三餐推荐食物
     *
     * @return
     */
    @Override
    @GetMapping("/get_recommend")
    public ResponseResult findRecommendFood() {
        return dFoodService.findRecomondFood();
    }

    /**
     * 食物查询
     *
     * @param food
     * @return
     */
    @PostMapping("/find_food")
    @Override
    public ResponseResult foodList(@RequestBody Food food) {

        return dFoodService.findFood(food);
    }

    @GetMapping("/all_food")
    @Override
    public ResponseResult allFood() {
        return dFoodService.findAllFood();
    }

    @Override
    @PostMapping("/add_comment")
    public ResponseResult addComment(@RequestBody Usercomment usercomment) {
        return dFoodService.addComment(usercomment);
    }

    @PostMapping("/resturand_locate/{rest_id}")
    @Override
    public ResponseResult getResturantLocation(@PathVariable("rest_id") String rest_id) {
        return dFoodService.findLocated(rest_id);
    }

    @GetMapping("/get_all_resturants")
    @Override
    public ResponseResult findAllResturant() {
        return dFoodService.findAllResturant();
    }

    @GetMapping("/get_resturant_detail")
    @Override
    public ResponseResult findResturantDetail(@RequestParam String id) {
        return dFoodService.findResturantDetail(id);
    }
}
